﻿using PureMVC.Patterns;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

///<summary>
///
///</summary>
public class ShopMediator : Mediator
{
    public new static string NAME = "ShopMediator";
    ShopView view;

    public ShopView ShopView
    {
        get
        {
            if(view == null)
            {
                GameObject obj = GameObject.Find("Canvas");
                view = obj.transform.Find("Shop").gameObject.GetComponent<ShopView>();
            }
            return view;
        }
    }
    public override void OnRemove()
    {
        ShopView.Close = null;
        base.OnRemove();
    }

    public ShopMediator()
    {
        ShopView.Init();
        ShopView.Close += () =>
        {
            StateManager.GetInstance.IsSkipEndPanel = true;
            ShopView.ClosePanel();
        };
        ShopView.Right += () =>
         {
             ShopView.ShowRightProp();
             ShopView.UpdateCurPropMoney();
         };
        ShopView.Left += () =>
        {
            ShopView.ShowLeftProp();
            ShopView.UpdateCurPropMoney();
        };
        ShopView.Buy += () =>
        {
            ShopView.BuyProp();
        };
    }
}
